<script setup lang="ts" name="menuItemTree">
const { menuList } = defineProps(['menuList'])
</script>

<template>
    <template v-for="(item, index) in menuList">
        <el-sub-menu v-if=" item.children && item.children.length > 0 && item.is_router === 0" :index="item.path">
            <template #title>
                <el-icon v-if="item.meta && item.meta.icon">
                    <component :is="item.meta.icon"></component>
                </el-icon>
                <span>{{ item.meta.title }}</span>
            </template>
            <menuItemTree :menuList="item.children" />
        </el-sub-menu>
        <el-menu-item v-else-if="(!item.children || item.children.length === 0) && item.is_router === 0" :index="item.path">
            <template #title>
                <el-icon v-if="item.meta && item.meta.icon">
                    <component :is="item.meta.icon"></component>
                </el-icon>
                <span>{{ item.meta.title }}</span>
            </template>
        </el-menu-item>
    </template>
</template>

<style scoped></style>